﻿@using OF.Component.Model;
@{
    ViewBag.Title = "ConfigPrice";
    Layout = "~/Views/Shared/layoutCommon.cshtml";
}
@{
    var expressList = (ViewBag.ExpressList as List<ExpressCompanyInfo>) ?? new List<ExpressCompanyInfo>();
}
@section style{
    <style>
        .col-sm-2 {
            width: 20%;
            float: left;
            text-align: right;
            margin-top: 5px;
        }

        .col-sm-3 {
            width: 30%;
            float: left;
        }

        .col-sm-1 {
            margin-top: 5px;
        }

        .form-group {
            margin-left: 20px;
        }
    </style>
}
<div>
    <section class="content-header">
        <h1>
            @ViewBag.CityName 配置业务
            <small></small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i>主页</a></li>
            <li><a href="/config/CityOpenManage?provinceid=@ViewBag.ProvinceId">省市业务开通</a></li>
            <li><a href="/config/FormBusiness?cityid=@ViewBag.CityId&provinceid=@ViewBag.ProvinceId&cityname=@ViewBag.CityName">配置业务</a></li>
            <li class="active">配置表单</li>
        </ol>
    </section>
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box box-primary">
                    <div class="box-header">
                        <div class="bs-example">
                            <ul class="nav nav-tabs">
                                <li role="presentation"><a href="@Url.Content("~/Config/ConfigForm?provinceid="+@ViewBag.ProvinceId+"&cityname="+@ViewBag.CityName+"&cgfid="+@ViewBag.CgfId+"")">配置表单</a></li>
                                <li role="presentation"><a href="@Url.Content("~/Config/ConfigPrice?provinceid="+@ViewBag.ProvinceId+"&cityname="+@ViewBag.CityName+"&cgfid="+@ViewBag.CgfId+"")">配置价格</a></li>
                                <li role="presentation"><a href="@Url.Content("~/Config/ConfigOrderExpire?provinceid="+@ViewBag.ProvinceId+"&cityname="+@ViewBag.CityName+"&cgfid="+@ViewBag.CgfId+"")">网办订单过期</a></li>
                                <li role="presentation"><a href="@Url.Content("~/Config/ConfigGuidance?provinceid="+@ViewBag.ProvinceId+"&cityname="+@ViewBag.CityName+"&cgfid="+@ViewBag.CgfId+"")">配置说明</a></li>
                                <li role="presentation" class="active"><a href="@Url.Content("~/Config/ConfigExpressTemplate?provinceid="+@ViewBag.ProvinceId+"&cityname="+@ViewBag.CityName+"&cgfid="+@ViewBag.CgfId+"")">配置快递</a></li>
                                <li role="presentation"><a href="@Url.Content("~/Config/ConfigView?provinceid="+@ViewBag.ProvinceId+"&cityname="+@ViewBag.CityName+"&cgfid="+@ViewBag.CgfId+"")">配置预览</a></li>
                            </ul>
                        </div>
                    </div>
                    <!-- /.box-header -->
                    <div class="box-header">
                        <div class="form-inline">
                            <div class="form-group">
                                <label>模版名称</label>
                                <input type="text" class="form-control" style="width:200px;" maxlength="20" id="templateName" autocomplete="off" />
                            </div>
                            <div class="form-group">
                                <label>快递公司</label>
                                <select name="expressId" id="expressId" class="form-control">
                                    <option value="-1">全部</option>
                                    @foreach (var item in expressList)
                                    {
                                        <option value="@item.ExpressCompanyID">@item.CompanyName</option>
                                    }
                                </select>
                            </div>
                            <div class="form-group">
                                <button type="button" class="btn btn-success btn-sm" id="btnSearch">查找</button>
                            </div>
                            <div class="form-group">
                                <button type="button" class="btn btn-success btn-sm" id="btnAdd">添加模版</button>
                            </div>
                            <h3 class="box-title"></h3>
                        </div>
                    </div>
                    <div id="datatable">

                    </div>

                    <div class="box-footer clearfix ">
                        <ul id="pagination" class="pagination pagination-sm no-margin pull-right"></ul>
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>
@section scriptsBottom{
    <script type="text/javascript">
        $(function () {
            search();
            $("#btnSearch").on("click", function () {
                search();
            });
            $("#btnAdd").on("click", function () {
                edit();
            })
        });
        function edit(id) {
            var url = '@Url.Action("ConfigExpressTemplateEdit", "Config")';
            url += "?bizTypeId=@ViewBag.BizTypeId";
            url += id ? "&id=" + id : "";

            var title = id == null||id=="" ? "添加快递价格配置" : "编辑快递价格配置";
            BMCW.showTopLayer(title, url, 1200, 700);
        }

        var pageIndex = 1;
        //列表加载||搜索
        function search() {
            var templateName = $("#templateName").val();
            var expressId = $("#expressId").val();

            var data = {
                "TemplateName": templateName,
                "ExpressID": expressId,
                "BizTypeId":@ViewBag.BizTypeId,
                "page": pageIndex,
                "rows":10
            };
            $("#datatable").load('@Url.Action("ConfigExpressTemplatePartial", "Config")', data, function (data) {
                document.getElementById('datatable').innerHTML = data;
                //分页显示
                $('#pagination').twbsPagination("destroy");
                $('#pagination').twbsPagination({
                    totalItems: $("#dataView").data("count"),
                    visiblePages: 10,
                    pageSize: 10,
                    startPage: parseInt(pageIndex),
                    onPageClick: function (event, page) {
                        pageIndex = page;
                        search();
                    }
                });
            })
        }
        function del(templateId) {
             var url = '@Url.Action("ConfigExpressTemplateDelete", "Config")';
            BMCW.DataConfirm("", function () {
                BMCW.ajax({
                    url: url,
                    type: "Post",
                    data: {
                        id: templateId
                    },
                    success: function (o) {
                        if (o.status == 0) {
                            BMCW.msg("删除成功", function () {
                                search();
                            });

                        } else {
                            BMCW.alert("删除失败");
                        }
                    }
                });
            })
        }
    </script>
}